Instruction: HOVER OVER heading above to see it animate.
Instruction: CLICK ON the heading above to see it animate.
Resource: Animate.css file.
If you have multiple page with the same classes assigned to them, all of these pages will animated. To prevent this, you can add or remove class for a given page.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>NOTE: Since we need to use jQuery we need to connect to it.
<link href="animated.css" rel="stylesheet" type="text/css" />
<script>
$(document).ready(function(e){
alert("jQuery is working correctly.")
}); // end ready
</script>
</head>
<script>
$(document).ready(function(e) {
animationHover("#myHeading", "tada");
animationClick("#myTitle", "tada");
// Animate when hover over
function animationHover(element, animation){
element = $(element);
element.hover(
function() {
element.addClass('animated ' + animation);
},
function(){
// wait for animation to finish before removing classes
window.setTimeout( function(){
element.removeClass('animated ' + animation);
}, 2000);
}
);
}; // end animateHover
function animationClick(element, animation){
element = $(element);
element.click( function() {
element.addClass('animated ' + animation);
// wait for animation to finish before removing classes
window.setTimeout( function(){
element.removeClass('animated ' + animation);
}, 2000);
}
);
}; // end animateClick}); // end ready
</script>
element.hover(While we could have used ONE function, it common practice to limit a function to one specific task at a time. We could have written the code as below and it would work the same:
function() {
element.addClass('animated ' + animation);
},
function(){
//wait for animation to finish before removing classes
window.setTimeout( function(){
element.removeClass('animated ' + animation);
}, 2000);
}
);
function animationHover(element, animation){
element = $(element);
element.hover(
function() {
element.addClass('animated ' + animation);
window.setTimeout( function(){
element.removeClass('animated ' + animation);
}, 2000);
}
);
}; //end animateHover
<h1 id="myHeading">CSS Animation Using Animate.css </h1>
<p><strong>Instruction: HOVER OVER</strong> heading above to see it animate.</p>
<h1 id="myTitle">Instructions for HOME page only</h1>
<p><strong>Instruction<: CLICK ON</strong> the heading above to see it animate.</p>